﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessLogic.DTO;
using BusinessLogic.Repository_Logic.Interfaces;
using TestSystem.Domain.Abstract;
using TestSystem.Domain.Entities.Authorisation;
using TestSystem.Domain.Repositories;

namespace BusinessLogic.Repository_Logic.Concentrate
{
    public class AccountRepositoryLogic : IAccountRepositoryLogic
    {
        private readonly IAccountRepository _accountRepository = new AccountRepository(); 

        public AccountDTO GetNewAccountDto()
        {
            return new AccountDTO {Roles = _accountRepository.Roles,User = new User()};
        }

        public void SaveAccount(AccountDTO accountDto)
        {
            _accountRepository.AddUser(accountDto.User);
        }

        public IEnumerable<User> Users()
        {
            return _accountRepository.Users;
        }

        public void RemoveUser(int id)
        {
            _accountRepository.RemoveUser(_accountRepository.Users.Single(user => user.UserId.Equals(id)));
        }
    }
}
